package com.hg.oa.module.home.presenter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.widget.TextView;

import com.hg.oa.common.BasePresenterImpl;

import java.util.ArrayList;

/**
 * Created by fengxiang on 2016/9/5.
 */
public class HomePresenterImpl extends BasePresenterImpl implements HomePresenter {


    public HomePresenterImpl(Context context) {
        super(context);
    }


    @Override
    public void switchPage(TextView titleView, String title, int resId, FragmentTransaction fragmentTransaction, ArrayList<Fragment> mFragments, Fragment fragment) {
        for (Fragment objFragment : mFragments) {
            if (objFragment.isAdded()) {
                fragmentTransaction.hide(objFragment);
            }
        }
        if (!fragment.isAdded()) {
            fragmentTransaction.add(resId, fragment);
        } else {
            fragmentTransaction.show(fragment);
        }
        titleView.setText(title);
        fragmentTransaction.commit();
    }
}
